package saeildamil.ch18.critical;

public class TransferThread extends Thread {
	SharedAccount sharedAccount;  //은행클래스

	
	public TransferThread(SharedAccount sharedAccount) {
		this.sharedAccount = sharedAccount;
	}

	@Override
	public void run() {
		//이몽룡 계좌 100만원 인출, 성춘향 계좌 100만원 입금 12번 반복
		for(int i=0; i<12; i++){
		sharedAccount.transfer(1000000);
			
			/*	synchronized(sharedAccount){
			try {
				sharedAccount.leeAccount.withdraw(1000000);
				System.out.println("이몽룡 계좌 100만원 인출");
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
			sharedAccount.sungAccount.deposit(1000000);
			System.out.println("성춘향 계좌 100만원 입금");
		}//end of synchronized     */	
	
	}// end of for
 }
}